package com.cmc.cloud.cmclink.doc.controller.admin;

import com.cmc.cloud.cmclink.doc.constants.UrlConstants;
import com.cmc.cloud.cmclink.doc.vo.arrivalnoticeprintsetupvo.ArrivalnoticePrintSetupCreateReqVO;
import com.cmc.cloud.cmclink.doc.vo.arrivalnoticeprintsetupvo.ArrivalnoticePrintSetupPageReqVO;
import com.cmc.cloud.cmclink.doc.vo.arrivalnoticeprintsetupvo.ArrivalnoticePrintSetupRespVO;
import com.cmc.cloud.cmclink.doc.vo.arrivalnoticeprintsetupvo.ArrivalnoticePrintSetupUpdateReqVO;
import com.cmes.framework.biz.advice.annotations.UseResponsePropertyAdvice;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import com.cmes.framework.common.pojo.CommonResult;
import com.cmes.framework.common.pojo.PageResult;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.*;
import java.util.*;


import com.cmes.framework.common.pojo.PageResult;

import com.cmc.cloud.cmclink.doc.entity.ArrivalnoticePrintSetupDO;
import com.cmc.cloud.cmclink.doc.convert.ArrivalnoticePrintSetupConvert;
import com.cmc.cloud.cmclink.doc.service.ArrivalnoticePrintSetupService;


/**
 * Arrival Notice 打印配置前端接口Controller
 * 
 * @author codegen
 */
@Tag(name = "管理后台 - Arrival Notice 打印配置")
@RestController
@Validated
@RequestMapping(UrlConstants.APPLICATION_URL+"/arrivalNotice")
public class ArrivalnoticePrintSetupController {

    @Resource
    private ArrivalnoticePrintSetupService arrivalnoticePrintSetupService;

    @Operation(summary = "创建Arrival Notice 打印配置")
	@PostMapping("/create")
    @PreAuthorize("@ss.hasPermission('doc:arrivalnotice:add')")
    public CommonResult<Void> createArrivalnoticePrintSetup(@Valid @RequestBody ArrivalnoticePrintSetupCreateReqVO createReqVO) {
        arrivalnoticePrintSetupService.createArrivalnoticePrintSetup(createReqVO);
        return CommonResult.success();
    }

    @Operation(summary = "更新Arrival Notice 打印配置")
	@PostMapping("/update")
    @PreAuthorize("@ss.hasPermission({'doc:arrivalnotice:edit','doc:arrivalnotice:save'})")
    public CommonResult<Void> updateArrivalnoticePrintSetup(@Valid @RequestBody ArrivalnoticePrintSetupUpdateReqVO updateReqVO) {
        arrivalnoticePrintSetupService.updateArrivalnoticePrintSetup(updateReqVO);
        return CommonResult.success();
    }

    @Operation(summary = "删除Arrival Notice 打印配置")
	@PostMapping("/delete/{id}")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('doc:arrivalnotice:delete')")
    public CommonResult<Void> deleteArrivalnoticePrintSetup(@PathVariable("id") Long id) {
        arrivalnoticePrintSetupService.deleteArrivalnoticePrintSetup(id);
        return CommonResult.success();
    }

    @Operation(summary = "获得Arrival Notice 打印配置")
	@GetMapping("/get/{id}")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<ArrivalnoticePrintSetupRespVO> getArrivalnoticePrintSetup(@PathVariable("id") Long id) {
        ArrivalnoticePrintSetupDO arrivalnoticePrintSetup = arrivalnoticePrintSetupService.getArrivalnoticePrintSetup(id);
        return CommonResult.success(ArrivalnoticePrintSetupConvert.INSTANCE.convert(arrivalnoticePrintSetup));
    }

    @Operation(summary = "获得Arrival Notice 打印配置列表")
	@GetMapping("/list")
    @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
    public CommonResult<List<ArrivalnoticePrintSetupRespVO>> getArrivalnoticePrintSetupList(@RequestParam("ids") Collection<Long> ids) {
        List<ArrivalnoticePrintSetupDO> list = arrivalnoticePrintSetupService.getArrivalnoticePrintSetupList(ids);
        return CommonResult.success(ArrivalnoticePrintSetupConvert.INSTANCE.convertList(list));
    }

    @Operation(summary = "获得Arrival Notice 打印配置分页")
	@PostMapping("/page")
    @UseResponsePropertyAdvice
    @PreAuthorize("@ss.hasPermission('doc:arrivalnotice:search')")
    public CommonResult<PageResult<ArrivalnoticePrintSetupRespVO>> getArrivalnoticePrintSetupPage(@Valid @RequestBody ArrivalnoticePrintSetupPageReqVO pageVO) {
        PageResult<ArrivalnoticePrintSetupDO> pageResult = arrivalnoticePrintSetupService.getArrivalnoticePrintSetupPage(pageVO);
        List<ArrivalnoticePrintSetupRespVO> results = ArrivalnoticePrintSetupConvert.INSTANCE.convertList(pageResult.getList());
        return CommonResult.success(new PageResult<>(results,pageResult.getTotal()));
    }
}
